Java - Using Linear Coordinates to Check Against AI [closed]

Posted by Oliver Jones on Programmers See other posts from Programmers or by Oliver Jones
Published on 2012-11-24T20:53:26Z Indexed on 2012/11/24 23:18 UTC
Read the original article Hit count: 231

I'm working on some artificial intelligence, and I want my AI not to run into given coordinates as these are references of a wall/boundary.

To begin with, every time my AI hits a wall, it makes a reference to that position (x,y). When it hits the same wall three times, it uses linear check points to 'imagine' there is a wall going through these coordinates.

I want to now prevent my AI from going into that wall again.

To detect if my coordinates make a straight line, i use:

private boolean collinear(double x1, double y1, double x2, double y2, double x3, double y3) {
    return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
}

This returns true is the given points are linear to one another.

So my problems are:

  1. How do I determine whether my robot is approaching the wall from its current trajectory?

  2. Instead of Java 'imagining' theres a line from 1, to 3. But to 'imagine' a line all the way through these linear coordinantes, until infinity (or close).

I have a feeling this is going to require some confusing trigonometry?

(REPOST: http://stackoverflow.com/questions/13542592/java-using-linear-coordinates-to-check-against-ai)

© Programmers or respective owner

Related posts about java

Related posts about artificial-intelligence